﻿using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.Encoders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpSM
{
    public class Sm3Util
    {
        /// <summary>
        /// 基于SM3获取摘要
        /// </summary>
        /// <param name="srcData">源数据</param>
        /// <returns></returns>
        public static string Digest(string srcData)
        {
           
                byte[] bytes = Encoding.UTF8.GetBytes(srcData);
                SM3Digest digest = new SM3Digest();
                digest.BlockUpdate(bytes, 0, bytes.Length);
                byte[] result = DigestUtilities.DoFinal(digest);
                return Hex.ToHexString(result);
         
        }
    }
}
